package ca.athabascau.quizmaster;
// Environment code for project COMP667-Proj

import jason.asSyntax.*;
import jason.environment.*;
import jason.environment.grid.GridWorldModel;
import jason.environment.grid.GridWorldView;

import java.sql.SQLException;
import java.util.logging.*;

import ca.athabascau.quizmaster.data.DataAccess;

public class QuizMASterEnvironment extends Environment {

    private Logger logger = Logger.getLogger("COMP667-Proj."+QuizMASterEnvironment.class.getName());
    private QuizMASterView view;
    private QuizMASterModel model;
    private DataAccess data;
    
     /** Called before the MAS execution with the args informed in .mas2j */
    @Override
    public void init(String[] args) {
        super.init(args);

        data=new DataAccess();
        model=new QuizMASterModel(10, 10, 1);
        view=new QuizMASterView(model, "Quizmaster view", 600);
        model.setView(view);
        try {
			addPercept("game",Literal.parseLiteral("ontology(target_ontology," + data.getOntology().replace(" ","_").toLowerCase() + ")."));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
      for(int x=1;x<11;x++)
      {
    	  addPercept("contestant"+x,Literal.parseLiteral("plays(user,user" + x+")."));
      }
    }

    @Override
    public boolean executeAction(String agName, Structure action) {
        logger.info("executing: "+action+", but not implemented!");
        return true;
    }

    /** Called before the end of MAS execution */
    @Override
    public void stop() {
        super.stop();
    }
    private class QuizMASterModel extends GridWorldModel{

 		protected QuizMASterModel(int arg0, int arg1, int arg2) {
 			super(arg0, arg1, arg2);
 			// TODO Auto-generated constructor stub
 		}
     	
     }
     private class QuizMASterView extends GridWorldView{

 		/**
		 * 
		 */
		private static final long serialVersionUID = -2531014399909271663L;

		public QuizMASterView(GridWorldModel model, String title, int windowSize) {
 			super(model, title, windowSize);
 			// TODO Auto-generated constructor stub
 		}
     	
     }
}
